
layui.use(['form', 'layer', 'table'], function(){

    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        table = layui.table;

    var datalist_url = $('.datalist_url').val();


    // Table 列表
    var tableIns = table.render({
        elem: '#dataTable',
        url : datalist_url,
        page : true,
        cellMinWidth : 95,
        //height : "full-100",
        limit : 10,
        limits : [10, 20, 50, 100],
        id : "tableList",
        cols : [[
            {field: 'id', title: '序号', align:'center', width:60},
            {field: 'order_no', title: '充值单号', align:'center'},
            {field: 'record_money', title: '充值金额', align:'center'},
            {field: 'gift_money', title: '赠送金额', align:'center'},
            {field: 'create_date', title: '充值时间', align:'center', minWidth:110, sort: true},
            {field: 'name', title: '姓名', align:'center'},
            {field: 'account_number', title: '会员号', align:'center'},
            {field: 'balance', title: '账户余额', align:'center'},
        ]]
    });

    // 搜索
    $(".search_btn").on("click", function(){
        if($('.name').val() != ''){
            table.reload("tableList", {
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    account_number: $('.searchBox').find('input[name=account_number]').val()  // 搜索的关键字
                }
            });
        }else{
            layer.msg("请输入搜索的内容");
        }
    });

    // 清空搜索
    $(".reset_btn").on("click", function(){
        table.reload("tableList", {
            where: {
                account_number: ''
            }
        });
    });

});